/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainForm.java
 *
 * Created on May 30, 2010, 4:26:12 PM
 */

package chris.braunschweiler.touchngo.view;

import chris.braunschweiler.touchngo.controller.IController;
import chris.braunschweiler.touchngo.controller.MyController;
import chris.braunschweiler.touchngo.level.GameEntity;
import chris.braunschweiler.touchngo.level.LevelEntity;
import chris.braunschweiler.touchngo.level.SwitchEntity;
import chris.braunschweiler.touchngo.view.GameEntityDialog.EntityType;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

/**
 *
 * @author chrisbraunschweiler
 */
public class MainForm extends javax.swing.JFrame implements ViewCallback {

    private IController controller;
    private LevelEntity currentLevel;
    private int levelCounter;
    private DefaultListModel levelIdListModel = new DefaultListModel();

    /** Creates new form MainForm */
    public MainForm() {
        initComponents();
        controller = new MyController(this);
        currentLevel = null;
        levelCounter = 0;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        levelIdList = new javax.swing.JList();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        addLevelButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel5 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        addHorizontalWallButton = new javax.swing.JButton();
        addVerticalWallButton = new javax.swing.JButton();
        addSwitchButton = new javax.swing.JButton();
        addGoalButton = new javax.swing.JButton();
        addBallButton = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        levelPanel = new javax.swing.JPanel();
        levelScrollPane = new javax.swing.JScrollPane();
        levelCanvas = new chris.braunschweiler.touchngo.view.LevelCanvas();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Load");

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Levels"));

        levelIdList.setModel(levelIdListModel);
        levelIdList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                levelIdListValueChanged(evt);
            }
        });
        levelIdList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                levelIdListMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(levelIdList);

        jButton3.setText("Remove");

        jButton4.setText("Clear");

        addLevelButton.setText("Add Level");
        addLevelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addLevelButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jButton3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButton4))
                    .add(addLevelButton)
                    .add(jScrollPane1, 0, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 198, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 45, Short.MAX_VALUE)
                .add(addLevelButton)
                .add(18, 18, 18)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton3)
                    .add(jButton4)))
        );

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jButton1)
                        .add(18, 18, 18)
                        .add(saveButton))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(8, 8, 8)
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(saveButton))
                .add(18, 18, 18)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Levels", jPanel1);

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 196, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 455, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Config", jPanel2);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Add Components"));

        addHorizontalWallButton.setText("Add Horizontal Wall");
        addHorizontalWallButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addHorizontalWallButtonActionPerformed(evt);
            }
        });

        addVerticalWallButton.setText("Add Vertical Wall");
        addVerticalWallButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addVerticalWallButtonActionPerformed(evt);
            }
        });

        addSwitchButton.setText("Add Switch");
        addSwitchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addSwitchButtonActionPerformed(evt);
            }
        });

        addGoalButton.setText("Add Goal");
        addGoalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addGoalButtonActionPerformed(evt);
            }
        });

        addBallButton.setText("Add Ball");
        addBallButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addBallButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(addHorizontalWallButton)
                    .add(addVerticalWallButton)
                    .add(addSwitchButton)
                    .add(addGoalButton)
                    .add(addBallButton))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(addHorizontalWallButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addVerticalWallButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addSwitchButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addGoalButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addBallButton)
                .addContainerGap(54, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Remove Components"));

        jButton5.setText("Remove");

        jButton6.setText("Remove All");

        org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel8Layout.createSequentialGroup()
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jButton5)
                    .add(jButton6))
                .addContainerGap(81, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .add(jButton5)
                .add(18, 18, 18)
                .add(jButton6)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Edit", jPanel5);

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 247, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 455, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("Properties", jPanel6);

        levelPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        org.jdesktop.layout.GroupLayout levelCanvasLayout = new org.jdesktop.layout.GroupLayout(levelCanvas);
        levelCanvas.setLayout(levelCanvasLayout);
        levelCanvasLayout.setHorizontalGroup(
            levelCanvasLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 372, Short.MAX_VALUE)
        );
        levelCanvasLayout.setVerticalGroup(
            levelCanvasLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 493, Short.MAX_VALUE)
        );

        levelScrollPane.setViewportView(levelCanvas);

        org.jdesktop.layout.GroupLayout levelPanelLayout = new org.jdesktop.layout.GroupLayout(levelPanel);
        levelPanel.setLayout(levelPanelLayout);
        levelPanelLayout.setHorizontalGroup(
            levelPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(levelScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
        );
        levelPanelLayout.setVerticalGroup(
            levelPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, levelScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 217, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(levelPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jTabbedPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 268, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, levelPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTabbedPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void addLevelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addLevelButtonActionPerformed
        //String levelId = JOptionPane.showInputDialog("Enter unique level id: ");
        String levelId;
        if(levelCounter<10){
            levelId = "Level0"+levelCounter;
        }
        else{
            levelId = "Level"+levelCounter;
        }
        levelCounter++;
        if(controller.levelExists(levelId)){
            JOptionPane.showMessageDialog(this, "A level with that ID already exists.");
        }
        else{
            //Add new level with given level id
            LevelEntity newLevel = new LevelEntity(levelId);
            currentLevel = newLevel;
            levelCanvas.setCurrentLevel(currentLevel);
            levelIdListModel.addElement(levelId);
            controller.addLevel(levelId, newLevel);
        }
    }//GEN-LAST:event_addLevelButtonActionPerformed

    private void addHorizontalWallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addHorizontalWallButtonActionPerformed
        if(currentLevel!=null){
            new GameEntityDialog(this,true,this,EntityType.HORIZONTAL_WALL).setVisible(true);
        }
        else{
            JOptionPane.showMessageDialog(this, "You have to specify the level to which to add " +
                    "the wall before trying to add the wall.");
        }
    }//GEN-LAST:event_addHorizontalWallButtonActionPerformed

    private void levelIdListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_levelIdListMouseClicked
        String selectedLevelId = (String)levelIdList.getSelectedValue();
        currentLevel = controller.getLevel(selectedLevelId);
        levelCanvas.setCurrentLevel(currentLevel);
    }//GEN-LAST:event_levelIdListMouseClicked

    private void levelIdListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_levelIdListValueChanged
        String selectedLevelId = (String)levelIdList.getSelectedValue();
        currentLevel = controller.getLevel(selectedLevelId);
        levelCanvas.setCurrentLevel(currentLevel);
    }//GEN-LAST:event_levelIdListValueChanged

    private void addVerticalWallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addVerticalWallButtonActionPerformed
        if(currentLevel!=null){
            new GameEntityDialog(this,true,this,EntityType.VERTICAL_WALL).setVisible(true);
        }
        else{
            JOptionPane.showMessageDialog(this, "You have to specify the level to which to add " +
                    "the wall before trying to add the wall.");
        }
    }//GEN-LAST:event_addVerticalWallButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        try {
            controller.saveGame(controller.getLevels());
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "An error occurred when trying to save the level: " +
                    ex.getMessage());
        }
    }//GEN-LAST:event_saveButtonActionPerformed

    private void addBallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBallButtonActionPerformed
        if(currentLevel!=null){
            new GameEntityDialog(this,true,this,EntityType.BALL).setVisible(true);
        }
        else{
            JOptionPane.showMessageDialog(this, "You have to specify the level to which to add " +
                    "the ball before trying to add the ball.");
        }
    }//GEN-LAST:event_addBallButtonActionPerformed

    private void addSwitchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addSwitchButtonActionPerformed
        if(currentLevel!=null){
            new SwitchEntityDialog(this,true,this,currentLevel.getAllEntities()).setVisible(true);
        }
        else{
            JOptionPane.showMessageDialog(this, "You have to specify the level to which to add " +
                    "the switch before trying to add the switch.");
        }
    }//GEN-LAST:event_addSwitchButtonActionPerformed

    private void addGoalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addGoalButtonActionPerformed
        if(currentLevel!=null){
            new GameEntityDialog(this,true,this,EntityType.GOAL).setVisible(true);
        }
        else{
            JOptionPane.showMessageDialog(this, "You have to specify the level to which to add " +
                    "the goal before trying to add the goal.");
        }
    }//GEN-LAST:event_addGoalButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addBallButton;
    private javax.swing.JButton addGoalButton;
    private javax.swing.JButton addHorizontalWallButton;
    private javax.swing.JButton addLevelButton;
    private javax.swing.JButton addSwitchButton;
    private javax.swing.JButton addVerticalWallButton;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private chris.braunschweiler.touchngo.view.LevelCanvas levelCanvas;
    private javax.swing.JList levelIdList;
    private javax.swing.JPanel levelPanel;
    private javax.swing.JScrollPane levelScrollPane;
    private javax.swing.JButton saveButton;
    // End of variables declaration//GEN-END:variables

    public void addHorizontalWall(GameEntity gameEntity) {
        if(currentLevel!=null){
            currentLevel.getHorizontalWalls().add(gameEntity);
            levelCanvas.repaint();
        }
        else{
            JOptionPane.showMessageDialog(this, "Unable to add the horizontal wall because" +
                    "there is currently no level selected to which to add the wall.");
        }
    }

    public void addVerticalWall(GameEntity gameEntity){
        if(currentLevel!=null){
            currentLevel.getVerticalWalls().add(gameEntity);
            levelCanvas.repaint();
        }
        else{
            JOptionPane.showMessageDialog(this, "Unable to add the vertical wall because" +
                    "there is currently no level selected to which to add the wall.");
        }
    }

    public void addBall(GameEntity gameEntity){
        if(currentLevel!=null){
            currentLevel.getBalls().add(gameEntity);
            levelCanvas.repaint();
        }
        else{
            JOptionPane.showMessageDialog(this, "Unable to add the ball because" +
                    "there is currently no level selected to which to add the ball.");
        }
    }

    public void addSwitch(GameEntity gameEntity) {
        currentLevel.getSwitches().add((SwitchEntity)gameEntity);
        levelCanvas.repaint();
    }

    public void addGoal(GameEntity gameEntity) {
        currentLevel.getGoals().add(gameEntity);
        levelCanvas.repaint();
    }
}
